﻿<title>出入库记录</title>
<link type="text/css" href="${ctx}/resources/css/ace.min.1.css"  rel="stylesheet" />
<table>
<tr>
<th>商品状态:</th>
<th width="70px;" class="label label-sm label-light arrowed"> <a href="${ctx}/admin/record/list${suffix}" >不限</a> </th>
<th width="70px;" class="label label-sm label-success arrowed"> <a href="${ctx}/admin/record/list${suffix}?state=1" >正常</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/record/list${suffix}?state=2" >禁用</a> </th>
</tr>
</table>

<div class="hr hr-5"></div>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
			<table id="sample-table-1" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>所属单位</th>
						<th>入库数量</th>
						<th>商品名称</th>
						<th>商品原价</th>
						<th>商品折扣价</th>
						<th>入库时间</th>
						<th>状态</th>
						<th>入库原因</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#list pager.itemList as u>
					<tr>
						<td>${u.id}</td>
						<td>
							<#if u.relativeId == 0>
								<a href="${ctx}/admin/record/list?relativeId=0" >平台</a>
							<#else>
								<@device cmd="get_estate_list">
									<#list estateList as o>
									<#if o.id == u.relativeId>
										<a href="${ctx}/admin/record/list?relativeId=${u.relativeId}" >${o.name!}</a>
									</#if>
									</#list>
								</@device>
							</#if>
						</td>
						<td>
							${u.amount!}
						</td>
						<td>
							<a href="${ctx}/admin/record/list?goodsId=${u.goodsId}&stock=${stock!}" >${u.goodsName!}</a>
						</td>
						<td>${u.goodsOldPrice!}</td>
						<td>${u.goodsDisPrice!}</td>
						<td>
							<#if u.createTime??>
								${tagUtils.formatDate(u.createTime)!}
							</#if>
						</td>
						<td>
						<#if u.state == 2>
							<span class="label label-sm label-warning arrowed">
								<#if adminRole ==1>
									配送中
								<#else>
									<a onclick="isSend('${ctx}/admin/record/submit?id=${u.id}')" title="确认收货">配送中<a>
								</#if>
							</span>
						<#else>
							<span class="label label-sm label-success arrowed">已配送</span>
						</#if>
						</td>
						<td>
							<#if u.status == 2>
									用户购买需求
							<#else>
								平台主动配送
							</#if>
						</td>
						
						<td>
						<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
								<#if adminRole ==1 && u.state == 2 && u.status == 1 >
									<a class="green" href="${ctx}/admin/record/edit-${u.id}" alt="编辑">
										<i class="icon-pencil bigger-130" title="编辑"></i>
									</a>
									<a class="red" onclick="isDel('${ctx}/admin/record/delete-${u.id}${suffix}')" alt="Delete">
										<i class="icon-trash bigger-130" title="删除"></i> 
									</a>
								<#else>
								</#if>
							
						</div>
						</td>
					</tr>
				</#list>
				</tbody>
			</table>
		</div>
	
		<div class="hr hr-18 dotted hr-double"></div>
		<@h.page pager=pager action="${ctx}/admin/record/list${suffix}" />
	</div><!-- /span -->
</div><!-- /row -->

<#if errorMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer red"></i>
		<span class="pink">${errorMsg!}</span>
	</h4>
</#if>

<#if infoMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer green"></i>
		<span class="pink">${infoMsg}</span>
	</h4>
</#if>

<script>
function isDel(url){
		if(!confirm("管理员请谨慎删除,如果该商品已经出库过,删除将不成功!确认要删除？")){ 
				return false;		
		}else{
			location.href = url;
		}
	}
function isSend(url){
		if(!confirm("请确认收货、是否仔细清点商品数量？")){ 
				return false;		
		}else{
			location.href = url;
		}
	}
function doState(checkbox,id) {
		if(checkbox.checked) {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/record/on?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		} else {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/record/off?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		}
	}
$(document).ready(function(){
	RP.addBreadcrumb([ {name:"出入库记录列表", active: true}]);
	<#if adminRole ==1>
		$("#breadcrumbs ul").append('&nbsp;&nbsp;&nbsp;&nbsp;<a href="${ctx}/admin/record/add2${suffix}"><i class="icon-zoom-in"></i><span class="label label-warning arrowed-in arrowed-in arrowed-right">配送商品</span></a>');
	</#if>	
});
</script>